package solved;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

/*
ID:		liluyan1
LANG:	JAVA
TASK:	sort3
*/
public class sort3 {
	public static void main(String[] args) throws IOException {
		BufferedReader f = new BufferedReader(new FileReader("sort3.in"));
		PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(
				"sort3.out")));
		new sort3().solve(f, out);
		out.close();
		System.exit(0);
	}
	
	private void solve(BufferedReader f, PrintWriter out) throws IOException {
		int N = read(f);
		int[] a = new int[N];
		int[] count = new int[3];
		for (int i=0; i<N; i++) {
			a[i] = read(f);
			count[a[i]-1]++;
		}
		
		int a12=0, a13=0, a23=0, a21=0, a31=0, a32=0;
		for (int i=0; i<count[0]; i++) {
			if (a[i] == 2) a12++;
			if (a[i] == 3) a13++;
		}
		
		for (int i=count[0]; i<count[0]+count[1]; i++) {
			if (a[i] == 1) a21++;
			if (a[i] == 3) a23++;
		}
		
		for (int i=count[0]+count[1]; i<N; i++) {
			if (a[i] == 1) a31++;
			if (a[i] == 2) a32++;
		}
		
		int total = 0;
		total += Math.min(a12, a21);
		int remain = Math.max(a12, a21) - total;
		
		total += Math.min(a13, a31);
		total += Math.min(a23, a32);
		
		total += 2*remain;
		
		out.println(total);
	}
	
	public int read(BufferedReader f) throws IOException {
		return Integer.parseInt(f.readLine());
	}
	
	public int[] read(BufferedReader f, int N) throws IOException {
		String[] t = f.readLine().split(" ");
		int[] a = new int[N];
		for (int i=0; i<N; i++) {
			a[i] = Integer.parseInt(t[i]);
		}
		return a;
	}
}
